package ljl.alg.jianzhioffer.round3.easy;

public class _57_twoSum {

    public int[] twoSum(int[] nums, int target) {
        int l = 0, r = nums.length - 1;

        while (true) {
            int sum = nums[l] + nums[r];
            if (sum > target)
                r--;
            else if (sum < target)
                l++;
            else
                return new int[] {nums[l], nums[r]};
        }
    }

}
